<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
//后台管理员控制器
class AdminController extends CommonController{
 	private $model;
	public function __init(){
		//调用CommonController里的构造函数
		parent::__init();
		//实例化Admin模型
		$this->model = new \Common\Model\Admin;
	}
	
	public function index(){
		//获得数据
		$data = $this->model->get();
		View::with('data',$data);
		View::make();
	}
	//添加
	public function add(){
		if(IS_POST){
		    //p(Q("post."));
			if(!$this->model->store()) View::error($this->model->getError());
			View::success('添加成功',U('index'));
		}

		View::make();
	}
	//编辑
	public function edit(){
		//2.修改
		if(!$this->model->edit()) View::error($this->model->getError());
		View::success('修改成功',U('index'));
		//1.获得旧数据
		$oldData = $adminModel->where("admin_id=" . Q('get.admin_id',0,'intval'))->find();
		View::with('oldData',$oldData);
		View::make();
	}
	

}

 ?>